﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using iLangl.Transport.Extensions;

namespace iLangl.Transport
{
	public class MockupTransport : ITransport
	{
		public event EventHandler NewPackageArrived;

		public String DestinationFolder { get; set; }
		#region ITransport Members

		public void SendRequest(UploadRequest request)
		{
			String uploadFilePath = Path.Combine(
				DestinationFolder,
				request.DeliveredFileName);

			if (!Directory.Exists(DestinationFolder))
			{
				Directory.CreateDirectory(DestinationFolder);
			}

			request.PackageData.WriteToFile(uploadFilePath);

			if (NewPackageArrived != null)
			{
				NewPackageArrived(this, EventArgs.Empty);
			}
		}




		public UploadLightResponse SendRequestSync(UploadLightRequest request)
		{
			if (NewPackageArrived != null)
			{
				NewPackageArrived(this, EventArgs.Empty);

			}

			return null;
		}

		#endregion
	}
}
